//简化document.getElementById
var get = function(id){
	return document.getElementById(id);
}

//菜单栏的显示隐藏
var show = function(id){
	for(var i=1; i<=5; i++){
		get("manager"+i).className = "hidden";
	}
	get("manager"+id).className = "show";
}

//提示信息
window.onload = function(){
	var scText = get("tips").value;
	var lucency = 1;
	var smgDiv;
	
	//获取页面的可视区域高度和宽度
	var wHeight = document.documentElement.clientHeight;
	var wWidth = document.documentElement.clientWidth;
	
	//消失提示
	function changeLucency(){
		var sc = get("resultMsg");
		sc.style.opacity = lucency;
		if(lucency >= 0){
			lucency -= 0.1;
			setTimeout(changeLucency,100);
			
			if (lucency < 0.1) {
				document.body.removeChild(smgDiv);
			}
		} 
	}
	
	//显示提示
	if(scText != "" && scText != null){
		smgDiv = document.createElement("div");
		smgDiv.innerHTML = scText;
		smgDiv.id = "resultMsg";
		smgDiv.className = "resultMsg";
		
		var msgColor = scText.substring(2,4);
		if(msgColor == "成功"){
			smgDiv.style.color = "green";
		} else {
			smgDiv.style.color = "red";
		}
		
		document.body.appendChild(smgDiv);
		
		//获取信息提示的宽和高
		var dHeight = smgDiv.offsetHeight;
		var dWidth = smgDiv.offsetWidth;
		//设置信息提示的left和top
		smgDiv.style.left = (wWidth-dWidth)/2 + "px";
		smgDiv.style.top = (wHeight-dHeight)/2 + "px";

		//设置2秒钟后消失提提示
		setTimeout(changeLucency,2000);
	}
}